
#include<stdio.h>
#include<math.h>
int  main()
{
	int  n;
	while(~scanf("%d",&n))
    {
    	int ans = 0;
	    while(n != 1)
	    {
	    	if(n % 2 == 0)
	    	{
	    		n /= 2;
	    		ans++;
			}
			else
			{
				n = 3 * n + 1;
				ans++;
			}
		}
	    printf("%d\n",ans % 3);
	}
	
}
